﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using QunYing.Model;
namespace QunYing.BLL
{
    /// <summary>
    /// VipPayOrder
    /// </summary>
    public partial class VipPayOrder
    {
        private readonly QunYing.DAL.VipPayOrder dal = new QunYing.DAL.VipPayOrder();
        public VipPayOrder()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int 缴费单ID)
        {
            return dal.Exists(缴费单ID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(QunYing.Model.VipPayOrder model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(QunYing.Model.VipPayOrder model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int 缴费单ID)
        {

            return dal.Delete(缴费单ID);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string 缴费单IDlist)
        {
            return dal.DeleteList(缴费单IDlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public QunYing.Model.VipPayOrder GetModel(int 缴费单ID)
        {

            return dal.GetModel(缴费单ID);
        }

        /// <summary>
        /// 得到一个对象实体，从缓存中
        /// </summary>
        public QunYing.Model.VipPayOrder GetModelByCache(int 缴费单ID)
        {

            string CacheKey = "VipPayOrderModel-" + 缴费单ID;
            object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
            if (objModel == null)
            {
                try
                {
                    objModel = dal.GetModel(缴费单ID);
                    if (objModel != null)
                    {
                        int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
                        Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
                    }
                }
                catch { }
            }
            return (QunYing.Model.VipPayOrder)objModel;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<QunYing.Model.VipPayOrder> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<QunYing.Model.VipPayOrder> DataTableToList(DataTable dt)
        {
            List<QunYing.Model.VipPayOrder> modelList = new List<QunYing.Model.VipPayOrder>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                QunYing.Model.VipPayOrder model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new QunYing.Model.VipPayOrder();
                    if (dt.Rows[n]["缴费单ID"] != null && dt.Rows[n]["缴费单ID"].ToString() != "")
                    {
                        model.缴费单ID = int.Parse(dt.Rows[n]["缴费单ID"].ToString());
                    }
                    if (dt.Rows[n]["会员卡号"] != null && dt.Rows[n]["会员卡号"].ToString() != "")
                    {
                        model.会员卡号 = dt.Rows[n]["会员卡号"].ToString();
                    }
                    if (dt.Rows[n]["经销商ID"] != null && dt.Rows[n]["经销商ID"].ToString() != "")
                    {
                        model.经销商ID = dt.Rows[n]["经销商ID"].ToString();
                    }
                    if (dt.Rows[n]["缴费金额"] != null && dt.Rows[n]["缴费金额"].ToString() != "")
                    {
                        model.缴费金额 = int.Parse(dt.Rows[n]["缴费金额"].ToString());
                    }
                    if (dt.Rows[n]["会员原级别"] != null && dt.Rows[n]["会员原级别"].ToString() != "")
                    {
                        model.会员原级别 = dt.Rows[n]["会员原级别"].ToString();
                    }
                    if (dt.Rows[n]["会员新级别"] != null && dt.Rows[n]["会员新级别"].ToString() != "")
                    {
                        model.会员新级别 = dt.Rows[n]["会员新级别"].ToString();
                    }
                    if (dt.Rows[n]["原到期时间"] != null && dt.Rows[n]["原到期时间"].ToString() != "")
                    {
                        model.原到期时间 = dt.Rows[n]["原到期时间"].ToString();
                    }
                    if (dt.Rows[n]["新到期时间"] != null && dt.Rows[n]["新到期时间"].ToString() != "")
                    {
                        model.新到期时间 = DateTime.Parse(dt.Rows[n]["新到期时间"].ToString());
                    }
                    if (dt.Rows[n]["原服务选项"] != null && dt.Rows[n]["原服务选项"].ToString() != "")
                    {
                        model.原服务选项 = dt.Rows[n]["原服务选项"].ToString();
                    }
                    if (dt.Rows[n]["新服务选项"] != null && dt.Rows[n]["新服务选项"].ToString() != "")
                    {
                        model.新服务选项 = dt.Rows[n]["新服务选项"].ToString();
                    }
                    if (dt.Rows[n]["提交时间"] != null && dt.Rows[n]["提交时间"].ToString() != "")
                    {
                        model.提交时间 = DateTime.Parse(dt.Rows[n]["提交时间"].ToString());
                    }
                    if (dt.Rows[n]["审核状态"] != null && dt.Rows[n]["审核状态"].ToString() != "")
                    {
                        model.审核状态 = dt.Rows[n]["审核状态"].ToString();
                    }
                    if (dt.Rows[n]["审核人"] != null && dt.Rows[n]["审核人"].ToString() != "")
                    {
                        model.审核人 = dt.Rows[n]["审核人"].ToString();
                    }
                    if (dt.Rows[n]["审核时间"] != null && dt.Rows[n]["审核时间"].ToString() != "")
                    {
                        model.审核时间 = DateTime.Parse(dt.Rows[n]["审核时间"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

